package com.ansion;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.ansion.bridgefragment.BridgeFragment;
import com.ansion.bridgefragment.BridgeFragmentx;
import com.ansion.utils.lifecycle.LifeCycleHelper;


/**
 * created by zhaoyuntao
 * on 28/02/2022
 * description:
 */
public interface BridgeInterface {
    default void startActivityForResult(Intent intent, @Nullable BridgeCallback callBack) {
        startActivityForResult(intent, null, callBack);
    }

    void startActivityForResult(Intent intent, Bundle bundle, @Nullable BridgeCallback callBack);

    static BridgeInterface getFragment(Context context) {
        Activity activity = LifeCycleHelper.findActivity(context);
        if (activity instanceof AppCompatActivity) {
            return BridgeFragmentx.getFragment((AppCompatActivity) activity);
        } else {
            return BridgeFragment.getFragment(activity);
        }
    }
}
